lay('#version').html('-v' + laydate.v);

//执行一个laydate实例
//接听
laydate.render({
    elem: '.deadline', //指定元素
    format: 'yyyy-MM-dd',
    // type:'datetime'
});

var twfJudge=ctx+"system/mTelWF";
$('#tab').bootstrapTable({
    url: twfJudge+'/forShow/judgeList/'+wfId,
    striped: true,                      //是否显示行间隔色
    cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
    pagination: true,                   //是否显示分页（*）
    sortable: true,                     //是否启用排序
    sortOrder: "asc",                   //排序方式
    sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
    pageNumber: 1,                      //初始化加载第一页，默认第一页,并记录
    search: false,                      //是否显示表格搜索
    strictSearch: true,
    showColumns: true,                  //是否显示所有的列（选择显示的列）
    showRefresh: true,                  //是否显示刷新按钮
    minimumCountColumns: 2,             //最少允许的列数
    clickToSelect: true,                //是否启用点击选中行
    //height: 500,                      //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
    uniqueId: "ID",                     //每一行的唯一标识，一般为主键列
    showToggle: true,                   //是否显示详细视图和列表视图的切换按钮
    cardView: false,                    //是否显示详细视图
    detailView: false,                  //是否显示父子表
    columns: [
        {field: 'pkId', title: '用户编号', hidden: true,visible: false},
        {field: 'WfId', title: 'WfId', hidden: true,visible: false},
        {field: 'visitTime', title: '评价时间', align: 'left', halign: 'center', width: 80, sortable: true},
        {field: 'VstDeptName', title: '回访单位', align: 'center'},
        {field: 'VstUserName', title: '回访人', align: 'left', halign: 'center'},
        {field: 'JudgeN', title: '满意度', align: 'center', sortable: true},
        {field: 'VstDesc', title: '回访意见', align: 'left', width: 110, halign: 'center'},
        {
            field: 'myOP', title: '查看', align: 'center', formatter: fmtToOPInGrid
        }]
});

function fmtToOPInGrid(value,row,index) {
    var id = value;
    var result = "";
    result += "<a href='javascript:;' class='btn btn-xs blue' onclick=\"huifang('" + id + "')\" title='查看'><span class='glyphicon glyphicon-pencil'></span></a>";
    return result;

}
function huifang(value) {
    $.modal.open("回访详情",twfJudge+"/forShow/JudgeDetail/"+value)
}
(function () {
//计算剩余字数
    var workRemark = $('.workRemark');
    var workRemarkI = $('.workRemarkI');
    var workRemarm = workRemarkI.text();
    var opinionth = workRemark.val().length;

    workRemark.attr('maxlength', workRemarm);
    workRemarkI.text(workRemarm - opinionth);
    workRemark.on('input propertychange', function () {
        workRemarkI.text(workRemarm - $(this).val().length);
    });

    //被诉主体
    var bslength=['拼汐汐','某东','某宝','某猫'];
    var bsHtml='';
    for (let i = 0; i<bslength.length  ; i++) {
        bsHtml+='<div class="tworkformprocess-gjz">'+bslength[i]+'</div>'
    }
    $("#tworkformprocess-zt").html(bsHtml);
    //关键字
    var gjzlength=['拼汐汐','某东','某宝','某猫'];
    var gjzHtml='';
    for (let i = 0; i<gjzlength.length  ; i++) {
        gjzHtml+=' <div class="tworkformprocess-gjz">'+gjzlength[i]+'</div>'
    }
    $("#tworkformprocess-bq").html(gjzHtml);
    //    var dfmClaNo = $('#dfmClaNo option:selected').text();
    //    $('#dfmCla').text(dfmClaNo)
    //Bootstrap-switch单选按钮操作

    $('[name="suggest"]').bootstrapSwitch({
        onText: "是",
        offText: "否",
        onColor: "success",
        offColor: "info",
        size: "mini",
        onSwitchChange: function (event, state) {
        }

    })
    $('[name="supervise"]').bootstrapSwitch({
        onText: "是",
        offText: "否",
        onColor: "success",
        offColor: "info",
        size: "mini",
        onSwitchChange: function (event, state) {
        }

    })
    $('[name="project"]').bootstrapSwitch({
        onText: "是",
        offText: "否",
        onColor: "success",
        offColor: "info",
        size: "mini",
        onSwitchChange: function (event, state) {
        }

    })
    $('[name="extract"]').bootstrapSwitch({
        onText: "是",
        offText: "否",
        onColor: "success",
        offColor: "info",
        size: "mini",
        onSwitchChange: function (event, state) {
        }

    })
    //Bootstrap-switch单选按钮赋值
    var r=true;
    $('[name="shieldPhone"]').bootstrapSwitch({
        onText: "是",
        offText: "否",
        onColor: "success",
        offColor: "info",
        size: "mini",
        state:r,
        onSwitchChange: function (event, state) {
        }

    })
    $('[name="openX"]').bootstrapSwitch({
        onText: "是",
        offText: "否",
        onColor: "success",
        offColor: "info",
        size: "mini",
        state:r,
        onSwitchChange: function (event, state) {
        }

    })
    $('[name="repetition"]').bootstrapSwitch({
        onText: "是",
        offText: "否",
        onColor: "success",
        offColor: "info",
        size: "mini",
        state:r,
        onSwitchChange: function (event, state) {
        }

    })
    $('[name="relation"]').bootstrapSwitch({
        onText: "是",
        offText: "否",
        onColor: "success",
        offColor: "info",
        size: "mini",
        state:r,
        onSwitchChange: function (event, state) {
        }

    })
    var a=$('#fmContent').text();
    $.ajax({
        url: "/api/bd/recommend",
        data: {title: '', content: a},
        type: "POST",
        dataType: "json",
        beforeSend: function () {
            $('#loading').modal('show');
        },
        complete: function () {
            $('#loading').modal('hide');
        },
        success: function (data) {
            // data = jQuery.parseJSON(data);  //dataType指明了返回数据为json类型，故不需要再反序列化
            var contentObj = document.getElementsByClassName("content")[0];
            if(data.data.length==0){
                contentObj.innerHTML = '没有数据';
            }else {
                var isHtml = "";
                var arr = data.data;

                for (var i = 0; i < data.data.length; i++) {
                    //       console.log(arr[i])
                    isHtml += '<div class="col-sm-12 work-box">';
                    isHtml += '<div class="work-box-top">';
                    isHtml += '<div class="col-sm-12 work-box-top-box">';
                    isHtml += '<div class="col-sm-6"><a  class="work-box-a" ><span style="">' + arr[i].title + '</span></a></div>';
                    isHtml += '<div class="col-sm-6 control-label" style="display: flex;align-items: center;padding: 0;justify-content: flex-end">';
                    isHtml += '<button type="button" class="btn btn-sm btn-primary" style="color: #206ef7;background-color: white;margin-right: 15px;">流程中';
                    isHtml += '</button>';
                    isHtml += '<i class="fa fa-chevron-circle-right"></i>';
                    isHtml += '</div>';
                    isHtml += '</div>';
                    isHtml += '<div class="col-sm-12 work-box-class">' + arr[i].content + '</div>';
                    isHtml += '<div class="col-sm-12 work-box-buttom">';
                    // isHtml += '<div class="col-sm-6">' + arr[i].subject + '</div>';
                    isHtml += '<div class="col-sm-8">' + arr[i].publish_time + '</div>';
                    isHtml += '<div class="col-sm-4">';
                    isHtml += '<div class="work-buttom control-label" style="margin: 0;padding: 0" onclick="copy('+'\''+arr[i].id+'\''+')">一键复制</div>';
                    isHtml += '</div>';
                    isHtml += '</div>';
                    isHtml += '</div>';
                    isHtml += '</div>';
                };
                contentObj.innerHTML = isHtml;
            }

        }

    });
})()
